#ifndef PLOTTER_H
#define PLOTTER_H

#include <QWidget>
#include <QVector>

class QwtPlot;
class QwtPlotGrid;
class QwtPlotCurve;
class QwtPlotZoomer;

class Plotter : public QWidget
{
    Q_OBJECT
public:
    Plotter(QWidget* parent = 0);
    ~Plotter();

    bool isZoomingEnabled() const;

    bool isLineVisible() const;
    bool isDataVisible() const;
    bool isGridVisible() const;

    void saveImage(const QString& filepath);
    void saveData(const QString& filepath);

public slots:
    void setZoomingEnabled(bool enable);

    void setLineVisible(bool visible);
    void setDataVisible(bool visible);
    void setGridVisible(bool visible);

    void update(const QString& xTitle, const QVector<double>& xData, const QString& yTitle, const QVector<double>& yData);

signals:
    void updated();

private:
    QwtPlot*       engine;
    QwtPlotGrid*   grid;
    QwtPlotCurve*  lineCurve;
    QwtPlotCurve*  dataCurve;
    QwtPlotZoomer* zoomer;

    QVector<double> xData;
    QVector<double> yData;
};

#endif // PLOTTER_H
